# 递归 进行sum
def sum(l):
    if l == []:
        return 0
    else:
        return l[0] + sum(l[1:])


# 通过递归统计个数
def count(l):
    if l == []:
        return 0
    else:
        return 1 + count(l[1:])


# 通过递归计算最大的数字
def max_num(l):
    if len(l) == 2:
        if l[0] > l[1]:
            return l[0]
        else:
            return l[1]
    sub_max = max_num(l[1:])
    if l[0] > sub_max:
        return l[0]
    else:
        return sub_max


#
# print(sum([1, 2, 3]))
#
# print(count([1, 2, 3, 4, 5]))
# print(max_num([4,33,2,1]))

def quicksort(array):
    if len(array) < 2:  # 基准条件
        return array
    else:  # 递归条件
        pivot = array[0]
        less = [i for i in array[1:] if i <= pivot] # 小于基准的排序
        greater = [i for i in array[1:] if i > pivot] # 大于基准的排序
        return quicksort(less) + [pivot] + quicksort(greater)

print(quicksort([10, 5, 2, 3]))